#include<bits/stdc++.h>
using namespace std;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T,n;
    int A[i],Ci,A[j],C;
    cin>>T>>n>>A[i]>>Ci;
    for(int i;1<=i<=n;i++){
        if(left(A[i])!=A[j]){
            Ci=0;
        }
        if(A[i]=A[j]){
            Ci=A[i];
        }
        else{
            Ci=0;
        }
    }
    C=!Ci;
    cout<<C<<endl;
    fclose(stdin);
    fclose(stdout);
    return 0;
}
